<link
	href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}"
	rel="stylesheet" type="text/css">
<div class="pageContent">
	<input id="workCenterCode" type="hidden">
	<div>
		<div class="treeleft">
			<div class="mini-toolbar">
				<input type="text" id="search1" /> <a class="buttonActive"
					href="javascript:void(0)" id="searchTree"><span><@label
						key='search.B'>搜索</@label></span></a>
			</div>
			<div id="menuBar" class="pBar pBarBorder">
				<ul class="toolBar">
					<li><a class="collapse" id="collapsable" title="<@label key="collapseAll.D">全部收起</@label>"><span><@label
								key="collapse.B">收起</@label></span>
					</a></li>
					<li><a class="expand" id="expandable" title="<@label key="expandAll.D">全部展开</@label>"><span><@label
								key="expand.B">展开</@label></span>
					</a></li>
				</ul>
			</div>
			<div layoutH="50" class="treebody">
				<div id="left">
					<ul id="tree" class="tree treeFolder expand">
						<#list workCenterTree as tree>
						<li><a rel="personnelList" tvalue="${tree.workCenterCode}"
							onclick="personnerlTreeNodeClick(this)">${tree.workCenterText}</a>
							<#if tree.childrens?? &&tree.childrens?size gt 0>
							<ul><@bpTree children=tree.childrens />
							</ul> </#if> </#list>
					</ul>
				</div>
			</div>

		</div>
		<div>
			<div class="pageHeader">
				<div class="searchBar">
					<ul class="searchContent">
						<li><label id="personnelCode"><@label
								key="personnelCode.C,colon">人员编号：</@label></label> <input type="text"
							name="personnelCode" /></li>
						<li><label><@label
								key="personnelName.C,colon">人员名称：</@label></label> <input type="text"
							name="personnelName" /></li>
						<li class="query">
							<div class="buttonActive">
								<div class="buttonContent">
									<button type="submit" id="reloadGridData"><@label
										key="query.B">查询</@label></button>
								</div>
							</div>
						</li>
					</ul>

				</div>
			</div>
		</div>
		<div style="padding: 0px; margin-top: -3px; overflow: hidden;">
			<div id="jGridForPersonnel" style="float: left; width: 100%;"></div>
		</div>
	</div>
</div>
<!-- 递归产生树的宏定义 -->
<#macro bpTree children> <#if children?? && children?size gt 0> <#list
children as child>
<li><a tvalue="${child.workCenterCode}" rel="personnelList"
	onclick="personnerlTreeNodeClick(this)">${child.workCenterText}</a>
	<#if child.childrens?? &&child.childrens?size gt 0>
	<ul><@bpTree children=child.childrens />
	</ul> </#if></li>
</#list> </#if> </#macro>

<script type="text/javascript">
	$(function() {
		$("#searchTree", navTab.getCurrentPanel()).baseTreeSearch({
			inputTextId : "#search1", //搜索框的id
			alertMsg : "<@label key='Tree_search_Input.D'>输入名称进行查询</@label>", //提示内容，要考虑国际化，传自后台
			$p : navTab.getCurrentPanel()
		});

		$("#collapsable", navTab.getCurrentPanel())._treeCollapsable({
			$p : navTab.getCurrentPanel()
		})

		$("#expandable", navTab.getCurrentPanel())._treeExpandable({
			$p : navTab.getCurrentPanel()
		})

	})
	
	$("#new", navTab.getCurrentPanel()).hover(function() {
		$("#list", navTab.getCurrentPanel()).attr("style", "display: block");
	})
	
	$("#list", navTab.getCurrentPanel()).mouseleave(function() {
		$("#list", navTab.getCurrentPanel()).attr("style", "");
	});

	function personnerlTreeNodeClick(ob) {
		var value = $(ob, navTab.getCurrentPanel()).attr("tvalue");
		$("#workCenterCode", navTab.getCurrentPanel()).val(value);
		initUI($("#menuBar", navTab.getCurrentPanel()));

		postData = {
			workCenterCode : value
		};
		$grid.jGrid('loadData');
	}

	var $page = DWZ.context(), $grid = $('#jGridForPersonnel', $page), postData = {};
	$grid.jGrid({
		layoutH : 130,
		width : 1172,
		base : '${rc.getContextPath()}/manage/personnel/',
		url : 'personnelListData',
		columns : [
				{
					field : 'personnelCode',
					group : 'ids',
					type : 'checkbox',
					width : 22
				},
				{
					field : '_index',
					text : '<@label key="serialNumber.C">序号</@label>',
					width : 50
				},
				{
					field : 'personnelCode',
					text : '<@label key="personnelCode.C">人员编号</@label>',
					width : 100,
					orderTable : 's'
				},
				{
					field : 'personnelName',
					text : '<@label key="userText.C">用户名称</@label>',
					width : 100
				},
				{
					field : 'workCenterText',
					text : '<@label key="workCenterText.C">工作中心名称</@label>',
					width : 140
				},
				{
					field : 'userCode',
					text : '<@label key="userCode.C">系统用户编号</@label>',
					width : 100
				},
				{
					field : 'lockFlag',
					text : '<@label key="lockFlag.C">锁定标志</@label>',
					width : 100,
					transform : function(data) {
						if (data == 0) {
							return '<@label    key="no.C">否</@label>';
						} else if (data == 1) {
							return '<@label    key="yes.C">是</@label>';
						}
					}
				},
				{
					field : 'createUser',
					text : '<@label key="createUser.C">创建人</@label>',
					width : 100,
					orderTable : 's'
				},
				{
					field : 'createDateTime',
					type : 'date',
					format : 'yyyy-MM-dd HH:mm:ss',
					text : '<@label key="createDateTime.C">创建时间</@label>',
					width : 180,
					orderTable : 's'
				},
				{
					field : 'modifyUser',
					text : '<@label key="modifyUser.C">修改人</@label>',
					width : 100,
					orderTable : 's'
				},
				{
					field : 'modifyDateTime',
					type : 'date',
					format : 'yyyy-MM-dd HH:mm:ss',
					text : '<@label key="modifyDateTime.C">修改时间</@label>',
					width : 180,
					orderTable : 's'
				} ],
		getQueryData : function() {
			return postData;
		},
		gridbars : [
		{
			icon : 'add',
			text : '<@label key="add.B">新增</@label>',
			title : '新增人员',
			target : 'dialog',
			href : 'personnel_add',
			data : {
				navTabId : "${navTabId!''}"
			},
			mask : true,
			width : 450,
			height : 260,
			rel : '',
			menuCode : "moveType_add"
		},
		{
			icon : 'edit',
			text : '<@label key="edit.B">编辑</@label>',
			title : '人员编辑',
			target : 'dialog',
			href : 'modifyPersonnel',
			data : {
				id : '{personnelCode}',
				navTabId : "${navTabId!''}"
			},
			mask : true,
			width : 450,
			height : 260,
			rel : '',
			menuCode : "moveType_edit"
		},
		{
			icon : 'delete',
			text : '<@label key="delete.B">删除</@label>',
			target : 'confirmTodo',
			href : 'deletePersonnel',
			action : function() {
				var personnelCodes = new Array();
				$('tbody [type=checkbox]', $grid).each(function() {
					if (this.checked) {
						var value = $(this).val();
						personnelCodes.push(value);
					}
				});
				if (personnelCodes.length) {
					alertMsg.confirm("确认要删除选择的人员数据吗？", {okCall : function() {
						$.ajax({
							type : 'POST',
							url : "${rc.getContextPath()}/manage/personnel/deletePersonnel",
							data : {
								navTabId : '${navTabId}',
								ids : personnelCodes.toString()
							},
							dataType : "json",
							timeout : 1000 * 10, //AJAX请求超时时间为10秒  
							success : function(data) {
								batchjobAjaxDone(data);
								$('#reloadGridData', $page).click();
							}
						});
					}});
				} else {
					alertMsg.error(DWZ.msg("alertSelectMsg"));
				}
			},
			menuCode : "moveType_del"
		}]
	});

	$('[name=personnelName]', $page).on('keydown', function(event) {
		var e = event || window.event;
		if (e.keyCode == 13) {
			$('#reloadGridData', $page).click();
		}
	});
	
	$('[name=personnelCode]', $page).on('keydown', function(event) {
		var e = event || window.event;
		if (e.keyCode == 13) {
			$('#reloadGridData', $page).click();
		}
	});

	$('#reloadGridData', $page).on('click', function() {
		postData = {
			personnelName : $('[name=personnelName]', $page).val(),
			personnelCode : $('[name=personnelCode]', $page).val()
		};
		$grid.jGrid('loadData');
	});
</script>